<template>
    <!-- 商品详情页 -->
    <div>
        <el-card class="box-card">
            <div class="static-content-item">
                <div>仓库信息:{{ this.$route.params.item_code }}</div>
            </div>
            <div class="static-content-item">
                <el-divider direction="horizontal"></el-divider>
            </div>
            <el-row>
                <el-col :span="8">
                    <div class="grid-content bg-purple">
                        <div style="margin-bottom: 10px;">
                            <el-button @click="xg(formData.id)" type="button" size="small"
                                to="UpdateWarehouse">编辑</el-button>
                            <el-button class="custom-button2" @mouseover="hover = true" @mouseout="hover = false"
                                @click="onSubmit">导出</el-button>
                            <el-button class="custom-button2" @click="onSubmit">导入</el-button>
                        </div>
                    </div>
                </el-col>
            </el-row>
            <el-form :model="formData" label-width="100px" size="medium">
                <el-descriptions>
                    <el-descriptions-item label="提交人" v-model="formData.create_by">{{ this.formData.create_by
                    }}</el-descriptions-item>
                    <el-descriptions-item label="操作时间" v-model="formData.create_time">{{ this.formData.create_time
                    }}</el-descriptions-item> 
                    <el-descriptions-item label="更新时间" v-model="formData.update_time">{{ this.formData.update_time
                    }}</el-descriptions-item>
                    <el-descriptions-item label="仓库编号" v-model="formData.ware_code">{{ this.formData.ware_code
                    }}</el-descriptions-item>
                    <el-descriptions-item label="仓库名称" v-model="formData.ware_name">{{ this.formData.ware_name
                    }}</el-descriptions-item>
                    <el-descriptions-item label="仓库容量" v-model="formData.ware_cap">{{ this.formData.ware_cap 
                    }}</el-descriptions-item>
                    <el-descriptions-item label="仓库主管" v-model="formData.ware_duty_man">{{ formData.ware_duty_man 
                    }}</el-descriptions-item>
                    <el-descriptions-item label="仓库地址" v-model="formData.ware_adr">{{ this.formData.ware_adr
                    }}</el-descriptions-item>
                    <el-descriptions-item label="状态" v-model="formData.ware_state">{{this.formData.ware_state}}
                    </el-descriptions-item> 
                </el-descriptions>
            </el-form>
        </el-card>
    </div>
</template>
<script>
import $http from '../http/base.js'
export default {
    components: {},
    props: {},
    data() {
        return {
            activeName: 'second',
            currentPage: 1,
            rows: 1,
            pageSize: 3,
            //Orderbuy分页查询
            currentPageo: 1,
            rowso: 1,
            pageSizeo: 3,
            Orderbuycx: [],
            dialogVisible: false,
            formData: {
                id: '',
                ware_code: "",
                ware_name: "",
                area_name: "",
                ware_cap: "",
                ware_state: '',
                ware_adr: '',
                is_default: "",
                is_lock: "",
                ware_duty_man: "",
                sort_code: '',
                create_by: '',
                create_time: "",
                update_by: "",
                update_time: "",
                is_del: 0,
            }, formInline: {
                item_code: "",
                unit: "",
            },
            input: {
                dw: '',
                hpsl: '',
                jhdj: '',
                bz: ''
            },
            tableDataxz: [],
            value1: '',
            value2: '',
           
        }
    },
    computed: {},
    watch: {},
    created() { },
    mounted: function () {
        this.RandomID();
        this.Orderbuy();
        this.fill();
        this.ItemSelectCode()
    },
    methods: {
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => { });
        }, handleClick(tab, event) {
            console.log(tab, event);
        },
        //查询详情
        ItemSelectCode() {
            $http.get('https://localhost:7020/api/bs_warehouseControllers/ItemSelectCode?ware_code=' + this.$route.params.ware_code)
                .then((res) => {
                    this.formData.ware_name = res.ware_name;
                    this.formData.ware_cap = res.ware_cap;
                    this.formData.ware_state = res.ware_state;
                    this.formData.ware_adr = res.ware_adr;
                    this.formData.ware_duty_man = res.ware_duty_man;
                    this.formData.sort_code = res.sort_code;
                    this.formData.create_by = res.create_by;
                    this.formData.create_time = res.create_time;
                    this.formData.update_by = res.update_by;
                    this.formData.ware_code = res.ware_code;
                    // alert(this.$route.params.item_code)
                    console.info(res)
                })
        },
        xg(row) {//编辑
            console.log(row);
            this.$router.push({ name: 'UpdateWarehouse', params: { id: row.id } })
        },
        RandomID() {//生成随机供应商编码
            // 定义一个函数生成编码
            function generateCode() {
                const date = new Date();
                const year = date.getFullYear();
                const month = (date.getMonth() + 1).toString().padStart(2, '0');
                const day = date.getDate().toString().padStart(2, '0');
                const hours = date.getHours().toString().padStart(2, '0');
                const minutes = date.getMinutes().toString().padStart(2, '0');
                const seconds = date.getSeconds().toString().padStart(2, '0');
                const fixedLetters = 'PF';
                return fixedLetters + year + month + day + hours + minutes + seconds;
            }
            // 使用函数生成编码
            const randomCode = generateCode();
            console.log(randomCode); // 示例打印：20231129113510Y
            this.formData.item_code = randomCode
        },
        handleRemove(file, fileList) {
            console.log(file, fileList);
        },
        handlePreview(file) {
            console.log(file);
        },
        //添加
        Insertuser() {
            $http.post('https://localhost:7020/api/BsItem/ItemAdd', this.formData)
                .then((res) => {
                    alert("新增成功！")
                    console.info(res)
                })
                .catch((err) => {
                    alert("新增失败！")
                    console.info(err);
                });
        }, toggleSelection(rows) {
            if (rows) {
                rows.forEach(row => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
            }
        },
        handleSelectionChange(val) {//固定列表
            this.multipleSelection = val;
            console.log(val);
        }, toggleSelection(rows) {//新增里的全选
            if (rows) {
                rows.forEach(row => {
                    this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
            }
        }, cz() {//重置
            this.formInline.unit = "";
            this.formInline.item_code = "";
        },
        handleSizeChange(pageSize) {//分页
            this.pageSize = pageSize;
            this.currentPage = 1;
            console.log(this.pageSize);
            this.Orderbuy();
        },
        handleCurrentChange(currentPage) {//分页
            this.currentPage = currentPage;
            console.log(this.currentPage);
            this.Orderbuy();
        }, handleSizeChangeo(pageSizeo) {//Orderbuy分页
            this.pageSizeo = pageSizeo;
            this.currentPageo = 1;
            console.log(this.pageSizeo);
            this.fill();
        },
        handleCurrentChangeo(currentPageo) {//Orderbuy分页
            this.currentPageo = currentPageo;
            console.log(this.currentPageo);
            this.fill();
        }, fill() {
            var tj = "1=1";
            //模糊查询
            if (this.formInline.item_code != "") {
                tj +=
                    " and item_code like concat('%',concat('" + this.formInline.item_code + "','%')) or item_name like concat('%',concat('" + this.formInline.item_name + "','%'))";
            }
            if (this.formInline.unit != "") {
                tj +=
                    " and inbill_state like concat('%',concat('" + this.formInline.inbill_state + "','%'))";
            }
            const token = localStorage.getItem('token');
            $http.post("https://localhost:7020/api/BsItem/bs_Item_xz_FenYe?pageSize=" + this.pageSizeo + "&currentPage=" + this.currentPageo + "&str=" + tj + "")
                .then((res) => {
                    console.log(res.list);
                    this.tableDataxz = res.list;
                    this.rows = res.count;
                }).catch((err) => {
                    alert('错误')
                    console.log(err);
                });
        }, Orderbuy() {
            var tj = "1=1";
            const token = localStorage.getItem('token');
            $http.post("https://localhost:7020/api/BsItem/wh_Orderbuy_d_FenYe?pageSize=" + this.pageSize + "&currentPage=" + this.currentPage + "&str=" + tj + "")
                .then((res) => {
                    console.log(res.list);
                    this.Orderbuycx = res.list;
                    this.rows = res.count;
                }).catch((err) => {
                    alert('错误')
                    console.log(err);
                });
        }
    }
}
</script>
<style scoped>
.custom-button:hover {
    border: #545C64;
    background-color: #79828a;
    /* 背景色 */
    color: white;
    /* 文本颜色 */
    /* 其他样式属性 */
  }
  
  .custom-button:focus {
    border: #545C64;
    background-color: #79828a;
    /* 背景色 */
    color: white;
    /* 文本颜色 */
    /* 其他样式属性 */
  }
.footer-nav {
    position: fixed;
    bottom: 0;
    right: 0px;
    height: 40px;
    background-color: #f0f0f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 1720px;
    float: right;
}

.footer-nav a {
    color: #333;
    text-decoration: none;
    font-size: 16px;
}

.footer-nav a:hover {
    color: #000;
}

.text {
    font-size: 14px;
}

.item {
    padding: 18px 0;
}

.box-card {
    width: 1500px;
    margin: auto;
}
</style> 
<style >
.el-input-number.full-width-input,
.el-cascader.full-width-input {
    width: 100% !important;
}

.el-form-item--medium {
    .el-radio {
        line-height: 36px !important;
    }

    .el-rate {
        margin-top: 8px;
    }
}

.el-form-item--small {
    .el-radio {
        line-height: 32px !important;
    }

    .el-rate {
        margin-top: 6px;
    }
}

.el-form-item--mini {
    .el-radio {
        line-height: 28px !important;
    }

    .el-rate {
        margin-top: 4px;
    }
}

.clear-fix:before,
.clear-fix:after {
    display: table;
    content: "";
}

.clear-fix:after {
    clear: both;
}

.float-right {
    float: right;
}
</style>

<style scoped>
div.table-container {
    table.table-layout {
        width: 100%;
        table-layout: fixed;
        border-collapse: collapse;

        td.table-cell {
            display: table-cell;
            height: 36px;
            border: 1px solid #e1e2e3;
        }
    }
}

.label-left-align ::v-deep .el-form-item__label {
    text-align: left;
}

.label-center-align ::v-deep .el-form-item__label {
    text-align: center;
}

.label-right-align ::v-deep .el-form-item__label {
    text-align: right;
}

.static-content-item {
    min-height: 20px;
    display: flex;
    align-items: center;

    ::v-deep .el-divider--horizontal {
        margin: 0;
    }
}

.Selected {
    display: inline-block;
}

.SInput {
    width: 190px;
}

.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 100px;
    margin: 0;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;

}

.el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
}
</style>